import requests
import re



def get_cookie(page):
    url1 = 'https://match.yuanrenxue.cn/match/13'
    cookies = {
    "sessionid": "29bpyrbwi0fiv52q7gpre5562goq2xtk"
    }
    params = {
        "page": page
    }
    response = requests.get(url1, headers=headers, cookies=cookies, params=params)
    resp_content = response.text
    cookies_data = re.findall(r"\('(.)'\)",resp_content)[18:]
    cookies_data = ''.join(cookies_data)
    return cookies_data
data_list = []
headers = {
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
}

url = "https://match.yuanrenxue.cn/api/match/13"
for i in range(1,6):
    params = {
        "page": i
    }
    cookies = {
        "sessionid": "29bpyrbwi0fiv52q7gpre5562goq2xtk",
        "yuanrenxue_cookie": get_cookie(i)
        }
    response = requests.get(url, headers=headers, cookies=cookies, params=params)
    # 提取出需要的数据
    datas = response.json()["data"]
    # 依次保存每页数据
    for i in datas:
        data_list.append(i["value"])
print(sum(data_list))

    
